package com.project.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.bean.ProjectBean;
import com.project.mapper.IProjectMapper;
import com.project.service.IProjectService;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Service
@Transactional
public class ProjectServiceImpl implements IProjectService {
    @Autowired
    private IProjectMapper mapper;
//    private int PAGESIZE;
    @Override
    public void add(ProjectBean project) {
        mapper.add(project);
    }

    @Override
    public PageInfo<ProjectBean> findByItem(int pageNo, String name, String status, String sort) {
        PageHelper.startPage(pageNo,PAGESIZE);
//        PageInfo<ProjectBean> info = new PageInfo<>(mapper.findByItem(name, status, sort));
        PageInfo<ProjectBean> info = PageInfo.of(mapper.findByItem(name, status, sort));
        return info;
    }

    @Override
    public ProjectBean findById(Integer id) {
        return mapper.findById(id);
    }

    @Override
    public List<ProjectBean> findByStatus() {
        return mapper.findByStatus();
    }
}
